#include <iostream>
#include <string>

using namespace std;

class Car
{
public:
    virtual void show() = 0;
};
class BMW : public Car
{
public:
    void show() { cout << "这是一辆宝马汽车！有基本配置"; }
};
class Audi : public Car
{
public:
    void show() { cout << "这是一辆奥迪汽车！有基本配置"; }
};
class Benc : public Car
{
public:
    void show() { cout << "这是一辆奔驰汽车！有基本配置"; }
};
// 装饰器
class CarDecorator01 : public Car
{
public:
    CarDecorator01(Car *p) : pCar(p){};
    void show()
    {
        pCar->show();
        cout << ",辅助驾驶";
    }
private: 
    Car *pCar;
};
class CarDecorator02 : public Car
{
public:
    CarDecorator02(Car *p) : pCar(p){};
    void show()
    {
        pCar->show();
        cout << ",自动校正";
    }

private:
    Car *pCar;
};
class CarDecorator03 : public Car
{
public:
    CarDecorator03(Car *p) : pCar(p){};
    void show()
    {
        pCar->show();
        cout << ",车道偏离";
    }

private:
    Car *pCar;
};

int main()
{
    Car *p1 = new CarDecorator01(new BMW());
    p1 = new CarDecorator02(p1);
    p1->show();
    cout << endl;

    Car *p2 = new CarDecorator02(new Audi());
    p2->show();
    cout << endl;

    Car *p3 = new CarDecorator03(new Benc());
    p3->show();
    cout << endl;

    return 0;
}